var basePage = require('../../../common/BasePage');
Page({
    behaviors: [basePage],
    data: {
        article_content: "没获取到文章详情",
    },
    onLoad: function(options) {
        //判断参数是否准确
        if (!options.article_id) {
            return wx.showModal({
                title: '提示',
                content: '文章信息有误',
                showCancel: false,
                success(res) {
                    if (res.confirm) {
                        wx.navigateBack({
                            delta: 1,
                        })
                    }
                }
            })
        }
        //请求文章详情
        this.request({
            url: this.data.host + '/home/article/detail?article_id=' + options.article_id
        }, this.get_detail_ok);
    },
    get_detail_ok(res) {
        this.setData({
            article_content: res.data.article_content.content.replace(/<img /ig, '<img width="100%" ')
        });
    }
})